home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
COMMUNIC
/
BULLETIN
/
0157.ZIP
/
GENERIC.ASM
< prev
next >
Wrap
Assembly Source File
|
1985-11-13
|
5KB
|
239 lines
title Generic Fido Driver
name generic
comment ~
updated 13 Nov 85
T. Jennings 12 July 85
This is a sample generic driver for
FIDO_GEN, seyup for the IBM PC. You will
of course have to rewrite it to fit your
particular hardware; refer to GENERIC.DOC
for details.
This is a terminate stay resident
program; install it by running it from
AUTOEXEC.BAT, only once. Who knows what
happens if you run it more than that. You
could of course make it a device driver,
but these are easier to debug.
end comment -> ~
;
;Modem port equates: IBM PC type 8250. IBM PC
;COM2 is 2f8.
;
BASE equ 3f8h ;COM1 base
MDATA equ BASE + 0 ; modem data port
MLINE equ BASE + 3 ; line control
MLSTAT equ BASE + 5 ; line status
MCNTRL equ BASE + 4 ; modem control
MSTAT equ BASE + 6 ; modem status
MBAUDL equ BASE + 0 ; baud rate low
MBAUDH equ BASE + 1 ; baud rate high
INTENB equ BASE + 1 ; int enb reg
INTID equ BASE + 2 ; interrupt ID
DLAB equ 80h ; divisor acc.
RDA equ 01h ; Rx char ready
TBE equ 20h ; Tx buff empty
MODE equ 03h ; 8 bits no par
RTS equ 2 ; RTS bit
DTR equ 1 ; DTR bit
B300 equ 0180h ; 300 baud
B1200 equ 0060h ; 1200 baud
B2400 equ 0030h ; 2400 baud
B9600 equ 000ch ; 9600 baud
code segment byte public 'code'
assume cs:code,ds:code
org 100h
;
;All this part does is install the driver
;in INT 14 and return to DOS, leaving the
;driver installed in memory.
;
main: mov dx,offset signon
mov ah,9 ;print string
int 21h ;call DOS
;
;Install our interrupt vector for INT 14.
;
mov ah,25h ;SET VECTOR
mov al,14h ;the int number
mov dx,offset int14 ;the vector
int 21h ;call DOS
;
;Calculate the paragraph address of our
;program; this is (segment +
;(ceiling endcode)) / 16
;
mov dx,offset endcode
add dx,15
shr dx,1
shr dx,1
shr dx,1
shr dx,1
; mov ax,cs ;our segment
; add dx,ax ;plus seg len
mov al,0
mov ah,31h ;terminate
int 21h
signon db 'Generic Fido Driver -- IBM PC COM1'
db 13,10,'T. Jennings 12 July 85'
db 13,10,'$'
page
;
;This is the actual INT 14 dispatcher. Fido
;calls this via INT 14. See GENERIC.DOC for
;details on what each call is.
;
;AH = function
;AL = function argument
;DX = IO port
;
int14: push ds ;be nice
push bp ;to the C code
mov bx,cs
mov ds,bx ;set DS:
mov bl,ah ;set to use
and bx,7 ;jump table
add bx,bx ;word ptr
call word ptr jmptbl[bx]
pop bp
pop ds
iret
;
;The function jump table.
;
jmptbl label word
dw baud ;AH = 0
dw write ;etc
dw read
dw status
dw init
dw uninit
dw dodtr
dw tick
page
;
;Initialize the serial port.
;
init: mov dx,MLINE ;set 8 data,
mov al,MODE ;no parity
out dx,al
mov dx,MDATA ;clear the UART
in al,dx ;of any garbage
in al,dx ;characters
in al,dx
in al,dx
ret
;
;Uninitialize the serial port. Not
;needed.
;
uninit: ret
;
;Set the baud rate as specified in AL. Since
;we do only NO PARITY and ONE STOP BIT, we
;can just mask off the rubbish.
;
baud: and al,11100000b ;strip it,
mov bx,B300
cmp al,01000000b ;300
je b1
mov bx,B1200
cmp al,10000000b ;1200
je b1
mov bx,B2400 ;2400
cmp al,10100000b
je b1
mov bx,B9600 ;else 9600
b1: pushf ;no ints
cli ;while fiddling
mov dx,MLINE ;set baud port
mov al,DLAB+MODE ;DLAB, 8 bits,
out dx,al
mov dx,MBAUDL ;low byte baud
mov al,bl
out dx,al
mov dx,MBAUDH ;now high byte
mov al,bh
out dx,al
mov dx,MLINE ;reset DLAB,
mov al,MODE
out dx,al ;select data
popf
ret
page
;
;Read a byte from the serial port; wait if
;necessary.
;
read: call status ;wait for one,
and ah,RDA
jz read
mov dx,MDATA ;get data port,
in al,dx ;get data.
ret
;
;Write a byte from AL to the modem.
;
write: push ax ;save it,
w1: call status ;wait til
and ah,TBE ;ready,
jz w1
pop ax
mov dx,MDATA ;get data port,
out dx,al ;put data.
ret
page
;
;Raise DTR if AL is nonzero, else lower it.
;
dodtr: cmp al,0 ;see if zero
mov al,RTS ;clear DTR
je d1 ;else ret it
mov al,RTS + DTR
d1: mov dx,MCNTRL
out dx,al
ret
;
;Return status in AX.
;
status: mov dx,MLSTAT
in al,dx ;line status
mov ah,al ;put in AH
mov dx,MSTAT
in al,dx ;modem in AL
ret
;
;Return the timer tick information: the tick
;interval (mS per tick) in DX, the interrupt
;vector in AL (0 - 255) and the number of ticks
;per second in AH.
;
tick: mov al,08h ;use INT 8,
mov ah,18 ;ticks per sec
mov dx,55 ;millisec/tick
ret
;
;The end of our program.
;
endcode label byte
code ends
end main